package org.springframework;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
	public static void main(String[] args) {
//		{
//			ApplicationContext context1 = new AnnotationConfigApplicationContext(MyConfig.class);
//			Student student1 = context1.getBean(Student.class);
//			System.out.println(student1);
//		}
		{
			ApplicationContext context2 = new ClassPathXmlApplicationContext("classpath:spring-config.xml");//断点
			Student student2 = (Student) context2.getBean("studentBean");
			System.out.println(student2);
		}
		// register
//		{
//			AnnotationConfigApplicationContext context3 = new AnnotationConfigApplicationContext();
//			context3.register(MyConfig.class);
//			context3.refresh();
//			Student student3 = context3.getBean(Student.class);
//			System.out.println(student3);
//		}
//		{
//			ApplicationContext context3 = new AnnotationConfigApplicationContext(MyConfig.class);
//			System.out.println(context3);
//		}
//		{
//			Resource classpathResource = new ClassPathResource("classpath:spring-config.xml");
//			XmlBeanFactory xmlBeanFactory = new XmlBeanFactory(classpathResource);
//			Student bean = xmlBeanFactory.getBean(Student.class);
//			System.out.println(bean);
//		}
	}
}